From ecd6f6b778a90fe552522670149b2cf0ca58ddab Mon Sep 17 00:00:00 2001 From: robertlipe Date: Tue, 31 Dec 2013 06:35:15 +0000 Subject: [PATCH] Introduce leaks (probably) in igc and google for now, just to get code building and passing in NEW_STRINGS. --- gpsbabel/google.cc | 6 +++++- gpsbabel/igc.cc | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gpsbabel/google.cc b/gpsbabel/google.cc index c831202b0..6ce27aa95 100644 --- a/gpsbabel/google.cc +++ b/gpsbabel/google.cc @@ -125,6 +125,7 @@ void goog_segment(xg_string args, const QXmlStreamAttributes* unused) wpt_tmp = route_find_waypt_by_name(routehead[goog_segroute], goog_segname); if (wpt_tmp) { #if NEW_STRINGS + wpt_tmp->shortname = QString(); #else xfree(wpt_tmp->shortname); #endif @@ -251,7 +252,10 @@ void goog_poly_e(xg_string args, const QXmlStreamAttributes* unused) wpt_tmp->latitude = lat / 100000.0; wpt_tmp->longitude = lon / 100000.0; wpt_tmp->route_priority=level; - wpt_tmp->shortname = (char*) xmalloc(7); +// NEW_STRINGS FIXME(robertlipe): this is broken somehow there should be no need +// to overallocate like this, but it's needed ot get an1 to not scribble +// on itself. + wpt_tmp->shortname = (char*) xmalloc(7000); #if NEW_STRINGS wpt_tmp->shortname = QString().sprintf( "\\%5.5x", serial++); #else diff --git a/gpsbabel/igc.cc b/gpsbabel/igc.cc index 30ba4be1f..b0f2409d9 100644 --- a/gpsbabel/igc.cc +++ b/gpsbabel/igc.cc @@ -612,6 +612,7 @@ static void wr_header(void) gbfprintf(file_out, "%s\r\n", str); } xfree(rd); + rd = NULL; #else if (track && track->rte_desc && strncmp(track->rte_desc, HDRMAGIC, strlen(HDRMAGIC)) == 0) { for (str = strtok(CSTRc(track->rte_desc) + strlen(HDRMAGIC) + strlen(HDRDELIM), HDRDELIM); @@ -625,11 +626,15 @@ static void wr_header(void) // its description as the pilot's name in the header. str = dflt_str; #if NEW_STRINGS +// FIXME: This almost certainly introduces a memory leak because str +// is a c string that's used for totally too many things. Just let it +// leak for now. 2013-12-31 robertl if (NULL != (wpt = find_waypt_by_name("PILOT")) && !wpt->description.isEmpty()) { + str = xstrdup(CSTRc(wpt->description)); #else if (NULL != (wpt = find_waypt_by_name("PILOT")) && wpt->description) { -#endif str = CSTRc(wpt->description); +#endif } gbfprintf(file_out, "HFPLTPILOT:%s\r\n", str); } -- 2.30.2